package com.dylan.foundation;

/**
 * @author dylan1009
 */
public class FirstThread extends Thread{
    public static void main(String[] args) {
        for (int i = 0; i < 200; i++) {
            //Thread的静态方法currentThread，获取当前线程
            System.out.println(Thread.currentThread().getName());
            if (i == 10) {
                //创建线程并启动
                new FirstThread().start();
                new FirstThread().start();
            }

        }
    }
    private int i=0;
    @Override
    public void run() {
        for (; i < 200; i++) {
            //获取当前线程名称
            System.out.println(this.getName() + " " + i);
        }
    }

}
